
// +----------------------------------------------------------------------
// | ajax 请求封装
// +----------------------------------------------------------------------
// | Author: 辰风沐阳 <23426945@qq.com>
// +----------------------------------------------------------------------

layui.extend({
    request: 'plugin/request'
}).define(['form', 'request'], function (exports) {
    var form = layui.form
        , request = layui.request;

    // 提交
    form.on('submit(LAY-user-login-submit)', function (obj) {
        request.ajax('/admin.php/login/login', 'post', 'json', {
            data: obj.field
        }, (res) => {
            console.log(res)
            layer.msg(res.msg, {
                shade: .3
                , time: 1200
            }, () => {
                if (res.code == 200) location.href = '/admin.php/';
            })
        })
        return false;
    });

    // 输出接口
    exports('login', {});
});